package com.twu.biblioteca;

import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * User: Thoughtworker
 * Date: 7/9/13
 * Time: 3:55 PM
 * To change this template use File | Settings | File Templates.
 */
public class Library {
        private ArrayList<LibraryItem> bookList;
        private ArrayList<LibraryItem> movieList;



    public Library(ArrayList<LibraryItem> bookList, ArrayList<LibraryItem> movieList) {

        this.bookList = bookList;
        this.movieList = movieList;

    }

    public ArrayList<LibraryItem> getMovieList() {
        return movieList;
    }

    public ArrayList<LibraryItem> getBookList() {

        return bookList;
    }


    public void printList(ArrayList<LibraryItem> list){
        System.out.println();
        for(LibraryItem book : list){
            System.out.println(book.getName());
        }

        System.out.println();

    }

    public Book lookUp(String target) {
        for (LibraryItem aBookList : bookList) {
            if (aBookList.getName().equals(target) && !((Book) aBookList).isReserved()) {
                return (Book) aBookList;
            }
        }

        //Book fake = new Book("Fake");
        return null;
    }

    public void reserveBook(String target)
    {
        Book bookLocation = lookUp(target);

        if(bookLocation != null )
        {
            bookLocation.setReserved(true);
            System.out.println("Thank You! Enjoy the book.\n");
        }
        else
        {
            System.out.println("Sorry we don't have that book yet.\n");
        }
    }
}
